﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySkiPatrolEntity;
using MySkiPatrolDAL;

namespace MySkiPatrolBLL
{
    public class ArticleBLO
    {
        ArticleDAO DAO = new ArticleDAO();

        public ArticleList GetArticles(ArticleRequest data)
        {
            //todo: check for null
            return DAO.GetArticles(data);
        }

        public Article GetArticle(Article data)
        {
            //todo: check for null
            return DAO.GetArticle(data);
        }

        public Article PutArticle(Article data)
        {
            //todo: check for null
            switch (data.DataTransaction.Action)
            {
                case DataAction.Add:
                    //TODO: create a Validator
                    data.ID = System.Guid.NewGuid().ToString();
                    data = DAO.AddArticle(data);
                    break;
                case DataAction.Delete:
                    data = DAO.DeleteArticle(data);
                    break;
                case DataAction.Update:
                    data = DAO.UpdateArticle(data);
                    break;
            }

            return data;
        }
    }
}
